#pragma once
#include <Windows.h>
#include <stdio.h>

class CConsoleEnv
{
private:
    CConsoleEnv();
    virtual ~CConsoleEnv();

public:
    static void Init();
};

CConsoleEnv::CConsoleEnv()
{
    AllocConsole();
    FILE* lpFile;
    freopen_s(&lpFile, "conin$", "r+t", stdin);
    freopen_s(&lpFile, "conout$", "w+t", stdout);
    freopen_s(&lpFile, "conout$", "w+t", stderr);
}

CConsoleEnv::~CConsoleEnv()
{
    fclose(stderr);
    fclose(stdout);
    fclose(stdin);
    FreeConsole();
}

void CConsoleEnv::Init()
{
    static CConsoleEnv ConsoleEnv;
}
